package com.zt.yongxinbao.service.impl;

import com.zt.yongxinbao.entity.EvaluationGoods;
import com.zt.yongxinbao.mapper.EvaluationGoodsMapper;
import com.zt.yongxinbao.service.EvaluationGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class EvaluationGoodsServiceImpl implements EvaluationGoodsService {
    @Autowired
    private EvaluationGoodsMapper evaluationGoodsMapper;
    @Override
    public List<EvaluationGoods> getComment(String goodsName) {
        List<EvaluationGoods> evaluationGoods=evaluationGoodsMapper.selectByGoodsName(goodsName);
        if (evaluationGoods!=null&&!evaluationGoods.isEmpty()) return evaluationGoods;
        return null;
    }

    @Override
    public Boolean insertComment(EvaluationGoods evaluationGoods) {
        if (evaluationGoodsMapper.insert(evaluationGoods)==1) return true;
        return false;
    }

    @Override
    public List<EvaluationGoods> getCommentByGoodsAndCustomerName(String goodsTitle, String customerName) {
        List<EvaluationGoods> evaluationGoods=evaluationGoodsMapper.selectByGoodsAndCustomerName(goodsTitle,customerName);
        if (evaluationGoods!=null&&!evaluationGoods.isEmpty()) return evaluationGoods;
        return null;
    }
}
